<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title></title>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/chat.css"/>
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/timeago.js"></script>
</head>
<body>
		<%@include file="include/topbar.jsp" %>
		
		<div class="container" style="margin-top: 60px">
			<div class="row">
			<jsp:include page="include/left.jsp" >
				<jsp:param value="new" name="tag"/>
			</jsp:include>
				<span class="span6">
					<ul class="breadcrumb" style="border-radius:3px 3px 0 0;margin-bottom:0px">
        									<li ><i class="icon-th-large"></i>你在想什么？</li>
     				</ul>

									
					<div class="wall" style="padding:20px;border-radius:0px;margin-top:0px">
						<textarea style="width:410px;height:70px"></textarea><br />
						<input id="sendmsg" type="button" class="btn btn-primary" value="发布" />
					</div>

					<ul class="breadcrumb" style="margin-bottom:0px;border-radius:3px 3px 0 0;margin-top:20px">
        									<li ><i class="icon-th-large"></i>信息流</li>
     				</ul>
     <div id="msgflow" class="wall" style="padding:20px;border-radius:0px; max-height:400px;overflow:auto;">
    <c:forEach var="log" items="${loglist}">
		<div class="post hasControls">
		<div class="avatar"><img class="avatar" src="downhead.jspx?pic=${log.pic}"></div>
			<div class="postContent thing">
				<div class="postHeader">
					<div class="info">
						<h3 class="chat-h3">${log.name eq employee.name ? '我' : log.name}</h3><abbr class="timeago" title="${log.time}"></abbr>
					</div>
				</div>
				<div class="postBody">
					<p>${log.desc}</p>
				</div>
				</div>
			</div>
	</c:forEach>
		</div>
</span>

				<span class="span3">
					<ul class="breadcrumb" style="margin-bottom:0px;border-radius:3px 3px 0 0;">
        									<li ><i class="icon-th-large"></i>我的任务</li>
     				</ul>
				<div class="wall">
					<ul>
						<c:if test="${empty tasklist}">
							<li>暂无任务</li>	
						</c:if>
						<c:forEach items="${tasklist }" var="task">
						
							<li><a href="task.jspx?gid=${task.goalId }">${task.name }</a></li>	
						</c:forEach>
					
					</ul>
						
				</div>
     				

				</span>
			</div>
			</div>
			
	<script type="text/javascript">
		$(document).ready(function() {
			$("#sendmsg").click(function() {
				var content = $("textarea").val();
				if(content != "") {
					$.ajax({
						url : 'sendmsg.jspx', 
						type : 'POST',
						data : {
							content : content
						},
						success : function() {
							$("textarea").val("");
						}
					});
				}
			});
			function receive() {
                ajax = $.ajax({
                    url: 'msgflow.jspx',
                    dataType: 'text',
                    success: function(data) {
                    	addMsg(data);
                        receive();
                    }
                });
            }
           receive();
		function addMsg(json) {
			var obj = $.parseJSON(json);
			var strHTML = "<div class='post hasControls'><div class='avatar'><img class='avatar' alt='" + obj.name + "' src='downhead.jspx?pic="+ obj.pic +"'></div>";
			var postHTML = "<div class='postContent thing'><div class='postHeader info'><h3 class='chat-h3'>" + (obj.name == "${sessionScope.employee.name}" ? "我" : obj.name) + "</h3><abbr class='timeago' title='" + obj.time +"'></abbr></div>";
			var bodyHTML = "<div class='postBody'><p>" + obj.desc + "</p></div></div></div>";
			var msgHTML = strHTML + postHTML + bodyHTML;
			$(msgHTML).prependTo("#msgflow");
			$("abbr.timeago").timeago();
		}
});
$("abbr.timeago").timeago();
</script>
</body>
</html>